import { Component, Fragment, useContext } from 'react'
import { MyContext } from './context'
// const { Consumer } = MyContext
export default class Child extends Component{
  static contextType = MyContext
  render() {
    const {name, age} = this.context
    return (
      <div>
        <div>name: {name}</div>
        <div>age: {age}</div>
        {/* <Consumer>
          {
            ({ name, age }) => {
              return (
                <Fragment>
                  <div>name: {name}</div>
                  <div>age: {age}</div>
                </Fragment>
              )
            }
          }
        </Consumer> */}
      </div>
    )
  }
}
export function ChildFunc() {
  const { name, age } = useContext(MyContext)
  return (
    <Fragment>
      <div>name: {name}</div>
      <div>age: {age}</div>
    </Fragment>
  )
}